var startingPage;
//获取传递过来的值
var url = decodeURI(window.location.href);
var aa = url.indexOf('=');
if (aa > -1) {
    url = url.substring(aa + 1);
}

//初始数据
function loadWebList() {
    var data = {
        "inform_id": url
    };
    $.ajax({
        url: "findInformByInformID",
        type: "POST",
        dataType: "json",
        data: JSON.stringify(data),
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = ' ';
            if (data.code == 500) {
                Swal.fire("提示", "查询数据失败", "error");
            } else {
                for (var i = 0; i < data.inform_List.length; i++) {
                    code += "<div class=\"single-blog-content light-box-content\">\n" +
                        "                                <div class=\"item-img\">\n" +
                        "                                <img style='width: 850px;height: 300px;' src='upload/" + data.inform_List[i].inform_image + "' alt=\"Blog\">\n" +
                        "                                </div>\n" +
                        "                                <div class=\"item-content\">\n" +
                        "                                    <ul class=\"blog-entry-meta\">\n" +
                        "                                        <li><i class=\"far fa-calendar-alt\"></i>" + data.inform_List[i].inform_Date + "</li>\n" +
                        "                                        <li><i class=\"fas fa-user\"></i><a href=\"#\">亦欢</a></li>\n" +
                        "                                        <li><i class=\"fas fa-comments\"></i>" + data.inform_List[i].inform_volume + "</li>\n" +
                        "                                        </li>\n" +
                        "                                    </ul>\n" +
                        "                                    <p>" + data.inform_List[i].inform_content + "</p>\n" +
                        "\n" +
                        "\n" +
                        "                                    <div class=\"blog-footer\">\n" +
                        "                                        <div class=\"row align-items-center\">\n" +
                        "                                            <div class=\"col-md-6\">\n" +
                        "\n" +
                        "                                            </div>\n" +
                        "                                            <div class=\"col-md-6\">\n" +
                        "                                                <div class=\"item-share\">\n" +
                        "                                                    <span class=\"share-title\">分享 <i\n" +
                        "                                                            class=\"fas fa-share-alt\"></i></span>\n" +
                        "                                                    <ul class=\"item-social\">\n" +
                        "                                                        <li><a href=\"#\" class=\"bg-facebook\"><i\n" +
                        "                                                                class=\"fab fa-facebook-f\"></i></a></li>\n" +
                        "                                                        <li><a href=\"#\" class=\"bg-twitter\"><i\n" +
                        "                                                                class=\"fab fa-twitter\"></i></a></li>\n" +
                        "                                                        <li><a href=\"#\" class=\"bg-google\"><i\n" +
                        "                                                                class=\"fab fa-google-plus-g\"></i></a></li>\n" +
                        "                                                        <li><a href=\"#\" class=\"bg-linkedin\"><i\n" +
                        "                                                                class=\"fab fa-linkedin-in\"></i></a></li>\n" +
                        "                                                        <li><a href=\"#\" class=\"bg-pinterest\"><i\n" +
                        "                                                                class=\"fab fa-pinterest-p\"></i></a></li>\n" +
                        "                                                    </ul>\n" +
                        "                                                </div>\n" +
                        "                                            </div>\n" +
                        "                                        </div>\n" +
                        "                                    </div>\n" +
                        "                                </div>\n" +
                        "                            </div>";
                }
                $("#SellerData").html(code);
            }
        }
    });
}

//通知
function inform_list() {
    startingPage = 0;
    var data = {
        "page": startingPage,
        "number": 5
    };
    $.ajax({
        url: "findInformByInformList",
        type: "POST",
        dataType: "json",
        data: JSON.stringify(data),
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = ' ';
            for (var i = 0; i < data.inform_List.length; i++) {
                code += "<li><a href=web-single-inform.html?id=" + data.inform_List[i].inform_id + ">" + data.inform_List[i].inform_title + "</a></li>";
            }
            $("#inform_1").append(code);

        }
    });
}

//按月份通知
function inform_list_2() {
    $.ajax({
        url: "findInformByInformCount",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = ' ';
            for (var i = 0; i < data.informList.length; i++) {
                code += "<li>" + data.informList[i].informDate + "<span style='margin-left: 60%;font-size: 30px;'>" + data.informList[i].informCount + "</span></li>";
            }
            $("#inform_2").append(code);

        }
    });
}

$(function () {
    var DATA = '';
    $.ajax({
        url: "JudgeLogin_3",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            if (data.code == 500) {
                DATA += " <li class=\"header-btn\">\n" +
                    "                                    <a href=\"web-login.html\" class=\"item-btn\"><i class=\"fas fa-plus\"></i>登录</a>\n" +
                    "                                </li>"
                Swal.fire("温馨提示", "请先登录", "warning");
                window.location.href = "web-user-404.html";
            } else {
                DATA += " <li class=\"header-login-icon\">\n" +
                    "                                    <a href=\"web-user-account.html\" class=\"color-light\" data-toggle=\"tooltip\"\n" +
                    "                                       data-placement=\"top\" title=\"Login/Register\">\n" +
                    "                                        <i class=\"far fa-user\">我的</i>\n" +
                    "                                    </a>\n" +
                    "                                </li>\n" +
                    "                                <li class=\"header-btn\">\n" +
                    "                                    <a  onclick='tuichu_1()' class=\"item-btn\"><i class=\"fas fa-plus\"></i>退出</a>\n" +
                    "                                </li>";
            }
            $("#userData").html("");
            $("#userData").append(DATA);
        }
    });
    loadWebList();
    inform_list();
    setTimeout("inform_list_2()", 100);
});
